#define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x<0) putchar('-'), x*=-1;
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
#include <algorithm>
#include <cstring>
using namespace std;
#define DEBUG

using ll=long long;
const int N=2e5+10;
int n, a[N], pmax[N]; //pmax[i]:i之前的a[]最大值
ll psum[N]; //前缀和

void init()
{
    read(n);
    for(int i=1; i<=n; i++) read(a[i]);
}   

void solve()
{
    init();
    for(int j=1; j<=n; j++)
    {
        pmax[j]=max(pmax[j-1], a[j]);
        psum[j]=psum[j-1]+a[j];
    }
    for(int k=1; k<=n; k++)
        quickwrite(pmax[n-k+1]+psum[n]-psum[n-k+1]), putchar(' ');
    puts("");
} 

#undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif
    #ifndef quickread
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #endif

    int T=1; scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}
